Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing props in markdown layout #3588

Merged
merged 2 commits into from
Jul 18, 2022

Conversation

charlesvdv
Copy link
Contributor

@charlesvdv charlesvdv commented Jun 13, 2022

Changes

  • Fix missing url props in markdown layout which should be there according to this document. Also referenced here 🐛 BUG: content.url missing from standalone markdown pages #1603 (comment) (the bug is marked as fixed but it looks like there is a regression from a recent change).

  • Add file props.
    This is maybe a bit more controversial. When doing Astro.glob("*.md"), the output contains the file path. I personally use this info to resolve resources which are referenced in as relative path from my frontmatter. For example, given this project:

src/pages
├── 404.astro
├── about.astro
├── blog
│   └── random-content
│       ├── my-blog-img.jpg
│       └── index.md
├── blog.astro
└── index.astro

In the src/pages/blog/random-content/index.md, I have the frontmatter prop img: "./my-blog-img.jpg". When I use Astro.glob, I use the markdown path to resolve the img props to a full path. This would be neat if I could do the same for mardown layout.

This might have impact on some projects if some frontmatter props have the key file.

Testing

A test is available to make sure the props are properly generated.

Docs

See withastro/docs#982

The `url` props was missing but should there according to [this
document](https://docs.astro.build/en/guides/markdown-content/#markdown-layouts).

The `file` props was not initially there but is quite useful when you
need to resolve file which are relative to the markdown file itself.
@changeset-bot
Copy link

changeset-bot bot commented Jun 13, 2022

🦋 Changeset detected

Latest commit: fe69fed

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
astro Patch
@e2e/astro-component Patch
@e2e/lit-component Patch
@e2e/preact-component Patch
@e2e/react-component Patch
@e2e/solid-component Patch
@e2e/svelte-component Patch
@e2e/e2e-tailwindcss Patch
@e2e/ts-resolution Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jun 13, 2022
@matthewp
Copy link
Contributor

@charlesvdv sounds good to me. If you want to go ahead and make the corresponding docs change and update the PR here, we can then merge them both.

@charlesvdv
Copy link
Contributor Author

@matthewp thanks for the review! I just made the necessary changes on the documation.

@JuanM04 JuanM04 merged commit 5d0edfc into withastro:main Jul 18, 2022
@astrobot-houston astrobot-houston mentioned this pull request Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants